package com.UI
{
	import com.*;
	import com.Engine.*;
	import com.Packet.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.external.*;
	import flash.filters.*;
	import flash.geom.*;
	import flash.system.*;
	import flash.text.*;
	import flash.ui.*;
	import flash.utils.*;
	
	import gs.*;
	import gs.easing.*;
	import gs.events.TweenEvent;
	
	import org.aswing.*;
	import org.aswing.border.*;
	import org.aswing.border.EmptyBorder;
	import org.aswing.colorchooser.*;
	import org.aswing.dnd.*;
	import org.aswing.event.*;
	import org.aswing.ext.*;
	import org.aswing.geom.*;
	import org.aswing.tree.AbstractLayoutCache;
	public class FrameStall extends JFrame
	{
		//members define
		private var panelItems:JPanel;
		private var labelInfo:JTextArea;
		//----------------------------------
		private var btn_close:JButton;
		public function FrameStall()
		{
			setClosable(false);
			setResizable(false);  
			setBorder(new EmptyBorder());
			
			btn_close = new JButton();
			btn_close.setLocation(new IntPoint(82, 0));
			btn_close.setSize(new IntDimension(27, 27));
			btn_close.setPreferredSize(new IntDimension(27, 27));
			this.getTitleBar().setCloseButton(btn_close);
			this.getTitleBar().setMinimizeHeight(32);
			
			//component creation
			setSize(new IntDimension(337, 418));
			setPreferredSize(new IntDimension(337, 418));
			var layout0:EmptyLayout = new EmptyLayout();
			getContentPane().setLayout(layout0);
			
			panelItems = new JPanel();
			panelItems.setLocation(new IntPoint(9, 6));
			panelItems.setSize(new IntDimension(319, 353));
			panelItems.setPreferredSize(new IntDimension(319, 353));
			var layout1:GridLayout = new GridLayout();
			layout1.setRows(4);
			layout1.setColumns(2);
			layout1.setHgap(3);
			layout1.setVgap(3);
			panelItems.setLayout(layout1);
			
			//labelInfo = new JTextArea();
			//labelInfo.setLocation(new IntPoint(50, -25));
			//labelInfo.setSize(new IntDimension(237, 24));
			//labelInfo.setPreferredSize(new IntDimension(237, 24));
			//labelInfo.setText("label");
			
			labelInfo = new JTextArea();
			labelInfo.setLocation(new IntPoint(50, -25));
			labelInfo.setSize(new IntDimension(26, 17));
			labelInfo.setText("label");
			
			//component layoution
			getContentPane().append(panelItems);
			getContentPane().append(labelInfo);
			
			setImages();
			this.setClipMasked(false);
			getContentPane().setClipMasked(false);
			//labelInfo.setEnabled(false);
		}
		private var _mallItems:Array = [];
		public function setImages():void
		{
			var img_char_background:DisplayObject = Client.getUIElement("img_stall_bg") as DisplayObject
			setBackgroundDecorator(new AssetBackground(img_char_background));
			setSizeWH(img_char_background.width,img_char_background.height);
			setLocationXY((Engine.W - img_char_background.width) / 2,(Engine.H - img_char_background.height)/2);
			
			btn_close.wrapSimpleButton(Client.getUIElement("btn_close") as SimpleButton);
			
			var filter:GlowFilter;
			var font:ASFont = new ASFont("宋体", 14, true, false, false, false);
			filter = new GlowFilter(0x000000, 1, 2, 2, 2);
			labelInfo.setBackgroundDecorator(null);
			labelInfo.setFont(font);
			labelInfo.filters = (new Array(filter));
			labelInfo.setForeground(ASColor.ORANGE);
			labelInfo.setText("陶陶陶的摊位");
			labelInfo.setAlignmentX(0.5);
			labelInfo.setEditable(false);
			//getTitleBar().setText("陶陶陶的摊位");
			//getTitleBar().getLabel().setFont(font);
			//getTitleBar().getLabel().setForeground(ASColor.ORANGE);
			//getTitleBar().getLabel().setTextFilters(new Array(filter));
			//getTitleBar().getLabel().setHorizontalAlignment(AsWingConstants.CENTER);
			
			for(var i:int = 0; i < 8; i++)
			{
				var item:PaneStallItem = new PaneStallItem;
				panelItems.append(item);
				_mallItems.push(item);
			}
			labelInfo.addEventListener(TextEvent.LINK, linkHandler);
			
			addEventListener(FrameEvent.FRAME_CLOSING,onFrameClosing);
			addEventListener(AWEvent.HIDDEN,onFrameClosing);
		}
		public static function onFrameClosing(e:Event):void
		{
			if(_frameParent == null)
				return;
			var teamDestX:int = (Engine.W - _frameParent.width)/2;
			var teamDestY:int = (Engine.H - _frameParent.height)/2;
			var tween:TweenLite = TweenLite.to(_frameParent, 0.3, {x:teamDestX, y:teamDestY});
			_frameParent = null;
		}
		public static function onFrameParentClosing(e:Event):void
		{
			if(_frameParent == null)
				return;
			_frameParent.removeEventListener(FrameEvent.FRAME_CLOSING,onFrameParentClosing);
			_frameParent.removeEventListener(AWEvent.HIDDEN,onFrameParentClosing);
			hide();
		}
		private function linkHandler(linkEvent:TextEvent):void 
		{
			//trace("linkEvent.target:"+linkEvent.target+",linkEvent.currentTarget:"+linkEvent.currentTarget);
			var dtemp:Array = (linkEvent.text as String).split(',');
			if(dtemp.length != 5)
			{
				return;
			}
			
			var obj:Object = new Object;
			obj.m_nCharId = int(dtemp[0]);
			obj.m_szCharName = dtemp[1];
			obj.m_nLevel = int(dtemp[2]);
			obj.m_nRace = int(dtemp[3]);
			obj.m_nGender = int(dtemp[4]);
			
			//trace(linkEvent.text);
			//FrameInfo.showMessageDialog("","这是一个物品"+linkEvent.text);
			var point:IntPoint = AsWingUtils.getStageMousePosition();
			FrameClickChar._objDest = obj;
			FrameClickChar._destCharId = int(obj.m_nCharId);
			FrameClickChar.show(_frame,point.x-_frame.x,point.y-_frame.y,false);
			//FrameClickChar.show(0,0);
			//trace("point.x:"+point.x+" point.y:"+point.y);
		}
		public function isSelfStall():Boolean
		{
			return(_array == CharInfo.m_arStallItems);
		}
		private var _array:Array = [];
		public function update(array:Array):void
		{
			_array = array;
			for each(var item:PaneStallItem in _mallItems)
			{
				item.item = null;
			}
			var nIndex:int = 0;
			for each(var obj:Object in array)
			{
				_mallItems[nIndex++].item = obj;
			}
			var m_szCharName:String = '';
			if(CharInfo.m_nGender == 0)
				m_szCharName += '<font color="#6fb5eb">';
			if(CharInfo.m_nGender == 1)
				m_szCharName += '<font color="#e81c73">';
			m_szCharName += '<a href=\"event:'+CharInfo.charId+','+CharInfo.charName+','+CharInfo.m_nLevel+','+CharInfo.m_nRace+','+CharInfo.m_nGender+'\"><u>';
			m_szCharName +=  CharInfo.charName + '</u></a></font>'
				
			labelInfo.setHtmlText((isSelfStall() ? m_szCharName : _strCharName) + "的摊位");
			labelInfo.pack();
			labelInfo.setLocationXY((width - labelInfo.width)/2,labelInfo.y);
			pack();
			this.paintImmediately();
		}
		public static var nWatchCharId:int = 0;
		public static var _nCharId:int = 0;
		public static var _strCharName:String = "";
		public static var _arStallItems:Array = [];
		public static function phStall_2100(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phStall_2100", msg);
			var nIndex:uint = 0;
			_nCharId = msg[nIndex++];
			_strCharName = msg[nIndex++];
			var array:Array = (_nCharId == CharInfo.charId ? CharInfo.m_arStallItems : _arStallItems);
			array.splice(0,array.length);
			var nCount:uint = msg[nIndex++];
			for(var i:int = 0; i < nCount; i++)
			{
				var obj:Object = new Object();
				array[i] = obj;
				obj.index = i;
				obj.csv_id = msg[nIndex++];
				if(obj.csv_id == 0)
				{
					continue;
				}
				obj.count = msg[nIndex++];
				obj.equip_level = msg[nIndex++];
				obj.equip_hp = msg[nIndex++];
				obj.equip_ap = msg[nIndex++];
				obj.equip_dp = msg[nIndex++];
				obj.equip_sp = msg[nIndex++];
				
				obj.equip_enhanceHL = msg[nIndex++];
				obj.equip_enhanceBD = msg[nIndex++];
				obj.equip_enhanceHS = msg[nIndex++];
				
				obj.equip_resistHL = msg[nIndex++];
				obj.equip_resistBD = msg[nIndex++];
				obj.equip_resistHS = msg[nIndex++];
				
				obj.equip_prop_BJ = msg[nIndex++];
				obj.equip_prop_SB = msg[nIndex++];
				obj.equip_prop_FJ = msg[nIndex++];
				obj.equip_prop_LJ = msg[nIndex++];
				
				obj.creator_char_gender = msg[nIndex++];
				obj.creator_char_name = msg[nIndex++];
				obj.creator_lover_gender = msg[nIndex++];
				obj.creator_lover_name = msg[nIndex++];
				
				obj.m_nUnitPrice = msg[nIndex++];
			}
			if(_nCharId == CharInfo.charId)
			{
				if(FrameStall.isShowing())
				{
					FrameStall.show(array,_frameParent);
				}
			}
			
			if(nWatchCharId == _nCharId)
			{
				FrameStall.show(array);
			}
		}
		public static var _frameParent:JFrame = null;
		public static var _frame:FrameStall = null;
		public static function show(array:Array,frameParent:JFrame = null):void
		{
			if(_frame == null)
			{
				_frame = new FrameStall();
				PanelMainHelp.getInstance().addChild(_frame);
			}
			if(!_frame.isShowing())
				_frame.setLocationXY((Engine.W - _frame.width) / 2,(Engine.H - _frame.height)/2);
			_frame.show();
			_frame.update(array);
			PanelMainHelp.getInstance().bringToTop(_frame);
			
			_frameParent = frameParent;
			
			if(_frameParent != null)
			{
				var teamDestX:int = (Engine.W - (_frameParent.width+_frame.width))/2;
				var teamDestY:int = (Engine.H - _frame.height)/2;
				
				var listDestX:int = teamDestX + _frame.width;
				var listDestY:int = teamDestY + (_frame.height - _frameParent.height)/2;
				
				var tween:TweenLite = TweenLite.to(_frame, 0.3, {x:teamDestX, y:teamDestY});
				var list_tween:TweenLite = TweenLite.to(_frameParent, 0.3, {x:listDestX, y:listDestY});
				
				_frameParent.addEventListener(FrameEvent.FRAME_CLOSING,onFrameParentClosing);
				_frameParent.addEventListener(AWEvent.HIDDEN,onFrameParentClosing);
			}
			else
			{
				_frame.setLocationXY((Engine.W - _frame.width) / 2,(Engine.H - _frame.height)/2);
			}
		}
		public static function hide():void
		{
			nWatchCharId = 0;
			if(isShowing())_frame.hide();
		}
		public static function isShowing():Boolean
		{
			return(_frame != null&& _frame.isShowing());
		}
		
		public static function showTakeOn(item:Object):void
		{
			show(CharInfo.m_arStallItems,FrameBag._frame);
			FrameStallTakeOn.show(item);
		}
	}
}

import com.*;
import com.UI.*;
import com.Engine.*;
import com.Packet.*;

import flash.display.*;
import flash.events.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.system.*;
import flash.text.*;
import flash.ui.*;
import flash.utils.*;

import gs.*;
import gs.easing.*;
import gs.events.TweenEvent;

import org.aswing.*;
import org.aswing.border.*;
import org.aswing.border.EmptyBorder;
import org.aswing.colorchooser.*;
import org.aswing.dnd.*;
import org.aswing.event.*;
import org.aswing.ext.*;
import org.aswing.geom.*;
import org.aswing.tree.AbstractLayoutCache;

class PaneStallItem extends JPanel{
	
	//members define
	private var panelItem:PanelItem;
	private var labelName:JLabel;
	private var labelPrice:JLabel;
	private var btn_stall_buy:JButton;
	private var btn_stall_take_off:JButton;
	
	/**
	 * MyPaneStallItem Constructor
	 */
	public function PaneStallItem(){
		//component creation
		setSize(new IntDimension(158, 86));
		setPreferredSize(new IntDimension(158, 86));
		var layout0:EmptyLayout = new EmptyLayout();
		setLayout(layout0);
		
		panelItem = new PanelItem();
		panelItem.setLocation(new IntPoint(7, 7));
		panelItem.setSize(new IntDimension(44, 44));
		panelItem.setPreferredSize(new IntDimension(44, 44));
		
		labelName = new JLabel();
		labelName.setLocation(new IntPoint(58, 7));
		labelName.setSize(new IntDimension(99, 20));
		labelName.setPreferredSize(new IntDimension(99, 20));
		labelName.setText("label");
		
		labelPrice = new JLabel();
		labelPrice.setLocation(new IntPoint(84, 36));
		labelPrice.setSize(new IntDimension(67, 17));
		labelPrice.setPreferredSize(new IntDimension(67, 17));
		labelPrice.setText("label");
		
		btn_stall_buy = new JButton();
		btn_stall_buy.setLocation(new IntPoint(54, 60));
		btn_stall_buy.setSize(new IntDimension(49, 25));
		btn_stall_buy.setPreferredSize(new IntDimension(49, 25));
		btn_stall_buy.setText("label");
		
		btn_stall_take_off = new JButton();
		btn_stall_take_off.setLocation(new IntPoint(54, 60));
		btn_stall_take_off.setSize(new IntDimension(49, 25));
		btn_stall_take_off.setPreferredSize(new IntDimension(49, 25));
		btn_stall_take_off.setText("label");
		
		//component layoution
		append(panelItem);
		append(labelName);
		append(labelPrice);
		append(btn_stall_buy);
		append(btn_stall_take_off);
		
		setImages();
	}
	public function setImages():void
	{
		setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_stall_item_bg") as DisplayObject));
		panelItem.enableClick = false;
		btn_stall_buy.wrapSimpleButton(Client.getUIElement("btn_stall_buy") as SimpleButton);
		btn_stall_take_off.wrapSimpleButton(Client.getUIElement("btn_stall_take_off") as SimpleButton);
		btn_stall_buy.setText('');
		btn_stall_take_off.setText('');
		
		var filter:GlowFilter;
		var font:ASFont = new ASFont("宋体", 13, false, false, false, false);
		filter = new GlowFilter(0x000000, 1, 2, 2, 5);
		labelName.setFont(font);
		labelName.setTextFilters(new Array(filter));
		labelName.setForeground(ASColor.WHITE);
		
		labelPrice.setFont(font);
		labelPrice.setTextFilters(new Array(filter));
		labelPrice.setForeground(ASColor.ORANGE);
		
		btn_stall_buy.addActionListener(function ():void{FrameStallBuy.show(_item);});
		btn_stall_take_off.addActionListener(onBtnStallTakeOff);
		btn_stall_buy.setVisible(false);
	}
	

	
	public function onBtnStallTakeOff(e:Event):void
	{
		Client.getInstance().sendPacketLogic(2102,[int(_item.index)]);
	}
	private var _item:Object = null;
	public function set item(val:Object):void
	{
		panelItem.item = val;
		_item = val;
		labelName.setText("");
		labelPrice.setText("");

		btn_stall_buy.setVisible(false);
		btn_stall_take_off.setVisible(false);
		if(_item == null)
		{
			return;
		}
		
		var objItemCSV:Object = Client.getInstance().GetItemCSV(item.csv_id);
		if(objItemCSV == null)
		{
			return;
		}
		labelName.setText(objItemCSV.name);
		labelPrice.setText(_item.m_nUnitPrice);

		btn_stall_buy.setVisible(!FrameStall._frame.isSelfStall());
		btn_stall_take_off.setVisible(FrameStall._frame.isSelfStall());
		pack();
		this.paintImmediately();
		
		
	}
	public function get item():Object
	{
		return _item;
	}
}

class FrameStallBuy extends JFrame
{
	//members define
	private var panelItem:PanelItem;
	private var labelPrice:JLabel;
	private var txtCount:JTextField;
	private var labelMoney:JLabel;
	private var btn_stall_buy:JButton;
	//----------------------------------
	private var btn_close:JButton;
	public function FrameStallBuy()
	{
		setClosable(false);
		setResizable(false);  
		setBorder(new EmptyBorder());
		
		btn_close = new JButton();
		btn_close.setLocation(new IntPoint(82, 0));
		btn_close.setSize(new IntDimension(27, 27));
		btn_close.setPreferredSize(new IntDimension(27, 27));
		this.getTitleBar().setCloseButton(btn_close);
		this.getTitleBar().setMinimizeHeight(32);
		
		
		//component creation
		setSize(new IntDimension(216, 225));
		setPreferredSize(new IntDimension(216, 225));
		var layout0:EmptyLayout = new EmptyLayout();
		getContentPane().setLayout(layout0);
		
		panelItem = new PanelItem();
		panelItem.setLocation(new IntPoint(87, 12));
		panelItem.setSize(new IntDimension(44, 44));
		panelItem.setPreferredSize(new IntDimension(44, 44));
		
		labelPrice = new JLabel();
		labelPrice.setLocation(new IntPoint(94, 74));
		labelPrice.setSize(new IntDimension(63, 17));
		labelPrice.setPreferredSize(new IntDimension(63, 17));
		labelPrice.setText("label");
		
		txtCount = new JTextField();
		txtCount.setLocation(new IntPoint(74, 98));
		txtCount.setSize(new IntDimension(77, 22));
		txtCount.setPreferredSize(new IntDimension(77, 22));
		
		labelMoney = new JLabel();
		labelMoney.setLocation(new IntPoint(74, 123));
		labelMoney.setSize(new IntDimension(77, 20));
		labelMoney.setPreferredSize(new IntDimension(77, 20));
		labelMoney.setText("label");
		
		btn_stall_buy = new JButton();
		btn_stall_buy.setLocation(new IntPoint(78, 152));
		btn_stall_buy.setSize(new IntDimension(49, 25));
		btn_stall_buy.setPreferredSize(new IntDimension(49, 25));
		btn_stall_buy.setText("label");
		
		//component layoution
		getContentPane().append(panelItem);
		getContentPane().append(labelPrice);
		getContentPane().append(txtCount);
		getContentPane().append(labelMoney);
		getContentPane().append(btn_stall_buy);
		
		setImages();
	}

	public function setImages():void
	{
		panelItem.enableClick = false;
		var img_char_background:DisplayObject = Client.getUIElement("img_stall_buy_bg") as DisplayObject
		setBackgroundDecorator(new AssetBackground(img_char_background));
		setPreferredSize(new IntDimension(img_char_background.width, img_char_background.height));
		setSizeWH(img_char_background.width,img_char_background.height);
		setLocationXY((Engine.W - img_char_background.width) / 2,(Engine.H - img_char_background.height)/2);
		
		btn_close.wrapSimpleButton(Client.getUIElement("btn_close") as SimpleButton);
		btn_stall_buy.wrapSimpleButton(Client.getUIElement("btn_stall_buy") as SimpleButton);
		btn_stall_buy.setText('');
		
		var filter:GlowFilter;
		var font:ASFont = new ASFont("宋体", 13, false, false, false, false);
		filter = new GlowFilter(0x000000, 1, 2, 2, 5);
		
		txtCount.setFont(font);
		txtCount.setForeground(ASColor.WHITE);
		txtCount.filters = new Array(filter);
		txtCount.setBackgroundDecorator(null);
		
		labelPrice.setFont(font);
		labelPrice.setTextFilters(new Array(filter));
		labelPrice.setForeground(ASColor.ORANGE);
		
		labelMoney.setFont(font);
		labelMoney.setTextFilters(new Array(filter));
		labelMoney.setForeground(ASColor.ORANGE);
		txtCount.addEventListener(FocusKeyEvent.FOCUS_KEY_UP,onTextInput);
		btn_stall_buy.addActionListener(onBtnStallBuy);
		
	}
	private function onTextInput(e:Event):void
	{
		labelMoney.setText( (int(txtCount.getText()) *　int(_item.m_nUnitPrice)).toString() );
	}
	public function onBtnStallBuy(e:Event):void
	{
		if(_item == null) return;
		if(int(txtCount.getText()) <= 0)
		{
			PanelMain.showInfo("请输入正确的购买数量");
			return;
		}
		
		Client.getInstance().sendPacketLogic(2103,[FrameStall._nCharId,int(_item.index),int(txtCount.getText())]);
		FrameStallBuy.hide();
	}
	private var _item:Object = null;
	public function update(item:Object):void
	{
		_item = item;
		panelItem.item = item;
		
		var objItemCSV:Object = Client.getInstance().GetItemCSV(item.csv_id);
		if(objItemCSV == null)
		{
			return;
		}
		txtCount.setText(_item.count);
		labelPrice.setText(_item.m_nUnitPrice);
		onTextInput(null);
	}
	public static var _frame:FrameStallBuy = null;
	public static function show(item:Object):void
	{
		if(isShowing())
		{
			hide();
			return;
		}
		if(_frame == null)
		{
			_frame = new FrameStallBuy();
			PanelMainHelp.getInstance().addChild(_frame);
		}
		
		_frame.show();
		_frame.update(item);
		PanelMainHelp.getInstance().bringToTop(_frame);
	}
	public static function hide():void
	{
		if(isShowing())_frame.hide();
	}
	public static function isShowing():Boolean
	{
		return(_frame != null&& _frame.isShowing());
	}
}

class FrameStallTakeOn extends JFrame
{
	//members define
	private var panelItem:PanelItem;
	private var labelName:JLabel;
	private var txtCount:JTextField;
	private var txtPrice:JTextField;
	private var btn_stall_take_on:JButton;
	//----------------------------------
	private var btn_close:JButton;
	public function FrameStallTakeOn()
	{
		setClosable(false);
		setResizable(false);  
		setBorder(new EmptyBorder());
		
		btn_close = new JButton();
		btn_close.setLocation(new IntPoint(82, 0));
		btn_close.setSize(new IntDimension(27, 27));
		btn_close.setPreferredSize(new IntDimension(27, 27));
		this.getTitleBar().setCloseButton(btn_close);
		this.getTitleBar().setMinimizeHeight(32);
		
		//component creation
		setSize(new IntDimension(216, 225));
		setPreferredSize(new IntDimension(216, 225));
		var layout0:EmptyLayout = new EmptyLayout();
		getContentPane().setLayout(layout0);
		
		panelItem = new PanelItem();
		panelItem.setLocation(new IntPoint(87, 12));
		panelItem.setSize(new IntDimension(44, 44));
		panelItem.setPreferredSize(new IntDimension(44, 44));
		
		labelName = new JLabel();
		labelName.setLocation(new IntPoint(60, 74));
		labelName.setSize(new IntDimension(97, 17));
		labelName.setPreferredSize(new IntDimension(97, 17));
		labelName.setText("label");
		
		txtCount = new JTextField();
		txtCount.setLocation(new IntPoint(74, 98));
		txtCount.setSize(new IntDimension(77, 20));
		txtCount.setPreferredSize(new IntDimension(77, 22));
		
		txtPrice = new JTextField();
		txtPrice.setLocation(new IntPoint(74, 123));
		txtPrice.setSize(new IntDimension(77, 20));
		txtPrice.setPreferredSize(new IntDimension(77, 22));
		
		btn_stall_take_on = new JButton();
		btn_stall_take_on.setLocation(new IntPoint(78, 152));
		btn_stall_take_on.setSize(new IntDimension(49, 25));
		btn_stall_take_on.setPreferredSize(new IntDimension(49, 25));
		btn_stall_take_on.setText("label");
		
		//component layoution
		getContentPane().append(panelItem);
		getContentPane().append(labelName);
		getContentPane().append(txtCount);
		getContentPane().append(txtPrice);
		getContentPane().append(btn_stall_take_on);

		setImages();
	}
	
	public function setImages():void
	{
		panelItem.enableClick = false;
		var img_char_background:DisplayObject = Client.getUIElement("img_stall_take_on_bg") as DisplayObject
		setBackgroundDecorator(new AssetBackground(img_char_background));
		setPreferredSize(new IntDimension(img_char_background.width, img_char_background.height));
		setSizeWH(img_char_background.width,img_char_background.height);
		setLocationXY((Engine.W - img_char_background.width) / 2,(Engine.H - img_char_background.height)/2);
		
		btn_close.wrapSimpleButton(Client.getUIElement("btn_close") as SimpleButton);
		btn_stall_take_on.wrapSimpleButton(Client.getUIElement("btn_stall_take_on") as SimpleButton);
		btn_stall_take_on.setText('');
		
		var filter:GlowFilter;
		var font:ASFont = new ASFont("宋体", 13, false, false, false, false);
		filter = new GlowFilter(0x000000, 1, 2, 2, 5);
		
		labelName.setFont(font);
		labelName.setTextFilters(new Array(filter));
		labelName.setForeground(ASColor.WHITE);
		
		txtCount.setFont(font);
		txtCount.filters = (new Array(filter));
		txtCount.setForeground(ASColor.WHITE);
		txtCount.setBackgroundDecorator(null);
		
		txtPrice.setFont(font);
		txtPrice.filters = (new Array(filter));
		txtPrice.setForeground(ASColor.ORANGE);
		txtPrice.setBackgroundDecorator(null);
		
		btn_stall_take_on.addActionListener(onBtnStallTakeOn);
	}
	public function onBtnStallTakeOn(e:Event):void
	{
		if(_item == null) return;
		if(int(txtCount.getText()) <= 0)
		{
			PanelMain.showInfo("请输入正确的出售数量");
			return;
		}
		if(int(txtPrice.getText()) <= 0)
		{
			PanelMain.showInfo("请输入正确的出售单价");
			return;
		}
		Client.getInstance().sendPacketLogic(2101,[_item.page,_item.index,int(txtCount.getText()),int(txtPrice.getText())]);
		FrameStallTakeOn.hide();
	}
	private var _item:Object = null;
	public function update(item:Object):void
	{
		_item = item;
		panelItem.item = item;
		
		var objItemCSV:Object = Client.getInstance().GetItemCSV(item.csv_id);
		if(objItemCSV == null)
		{
			return;
		}
		txtCount.setText(_item.count);
		labelName.setText(objItemCSV.name);
	}
	public static var _frame:FrameStallTakeOn = null;
	public static function show(item:Object):void
	{
		if(isShowing())
		{
			hide();
			return;
		}
		if(_frame == null)
		{
			_frame = new FrameStallTakeOn();
			PanelMainHelp.getInstance().addChild(_frame);
		}
		
		_frame.show();
		_frame.update(item);
		PanelMainHelp.getInstance().bringToTop(_frame);
	}
	public static function hide():void
	{
		if(isShowing())_frame.hide();
	}
	public static function isShowing():Boolean
	{
		return(_frame != null&& _frame.isShowing());
	}
}